package com.talent.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.talent.web.model.TalentResult;
import com.talent.web.model.entity.TlFile;
import com.talent.web.model.query.FileQuery;
import com.talent.web.service.ITlFileService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author watson
 * @Description"
 * @date: 2025/3/2 14:30
 */

@RestController
@RequestMapping("file")
@RequiredArgsConstructor
public class FileController {




    private final ITlFileService fileService;



    @GetMapping("page")
    public TalentResult<IPage<TlFile>> page(@RequestParam(defaultValue = "1") int current,
                                             @RequestParam(defaultValue = "10") int pageSize, FileQuery query){
        IPage<TlFile> page = fileService.page(current, pageSize, query);
        return TalentResult.success(page);
    }


//    @GetMapping("download")
//    public void downloadFile(String fileName, HttpServletResponse response) throws Exception {
//
//        response.setContentType("application/octet-stream");
//        response.setCharacterEncoding("utf-8");
//        response.setHeader("Content-disposition","attachment,filename*=utf-8''"+ URLEncoder.encode(fileName,"UTF-8"));
//        GetObjectResponse object = minioClient.getObject(GetObjectArgs.builder()
//                .bucket("")
//                .object(fileName)
//                .build());
//
//        object.transferTo(response.getOutputStream());
//    }
}
